home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / asmutil / asm_n_z.zip / SMALLCOM.ASM < prev    next >
Assembly Source File  |  1986-12-11  |  2KB  |  84 lines

  1.          page   65,132 
  2.          ;a very small command processor: smallcom
  3.          ;reads commands, runs them via int 2eh
  4.          ;exit with command: x  (either case)
  5. cseg     segment
  6.          assume cs:cseg,ds:cseg,es:cseg
  7.  
  8. cr       equ    13
  9. lf       equ    10
  10.          org    80h      ;length of parm
  11. pspparml db     ?
  12.          org    81h      ;parm from caller
  13. pspparm  db     ?
  14.          org    100h
  15. begin:   jmp    start
  16.          db     'Copyright 1986 Arnold B. Krueger GPW MI 48236'
  17.          db     20 dup('stack ')
  18. stack    equ    $
  19. stkseg   dw     0        ;save ss here
  20. stkptr   dw     0        ;save sp here
  21. msg1     db     'Enter command or x to exit',cr,lf,'$'
  22. msg2     db     'Command complete'
  23. crlf     db     cr,lf,'$'
  24.  
  25.  
  26. start:   
  27.          mov    sp,offset stack
  28.          mov    bx,offset cs:endcode
  29.          add    bx,15
  30.          mov    cl,4
  31.          shr    bx,cl
  32.          mov    ah,4ah               ;release unneeded storage
  33.          int    21h
  34.  
  35.          mov    stkseg,ss
  36.          mov    stkptr,sp
  37. command:         
  38.          mov    dx,offset msg1
  39.          mov    ah,9h
  40.          int    21h
  41.  
  42.          mov    pspparml,78h         ;max possible bytes read
  43.          mov    dx,offset pspparml   ;where read buffer is
  44.          mov    ah,0ah               ;read buffer
  45.          int    21h
  46.  
  47.          mov    dx,offset crlf       ;send cr,lf to save command
  48.          mov    ah,9h                ;type out string
  49.          int    21h
  50.  
  51.          cmp    pspparml+1,1         ;read just one byte?
  52.          jne    notexit
  53.          cmp    pspparml+2,'X'       ;exit command?
  54.          je     endexit
  55.          cmp    pspparml+2,'x'
  56.          je     endexit
  57. notexit:
  58.          mov    si,offset pspparml+1       ;ds:si is command to run
  59.          int    2eh                        ;have command.com execute parm
  60.  
  61.          mov    ss,cs:stkseg        ;restore environment
  62.          mov    sp,cs:stkptr
  63.          push   cs
  64.          pop    ds                  ;restore ds
  65.          push   cs
  66.          pop    es                  ;restore es
  67.  
  68.          mov    dx,offset msg2      ;send out message
  69.          mov    ah,9h
  70.          int    21h
  71.          jmp    command
  72.         
  73. endexit:
  74.          mov    ah,4ch
  75.          int    21h
  76.  
  77. endcode  equ    $
  78.  
  79. cseg     ends
  80.          end    begin
  81.  
  82. 
  83.  
  84.